# from core.support import set_cutscene
from core.item import Item
from core.action import Action
from core.support import set_cutscene, get_game

class crabcake(Item):
    def __init__(self):
        Item.__init__(self, "crab cake")    # do basic initialization for every item
        self.been_in_bathroom = False
        
        # build list of actions
        self.add_action(EatCrabCake)
    
    def get_description(self):
        return "Crab Cake"

# define actions for this item

class EatCrabCake(Action):
    def __init__(self):
        Action.__init__(self, "eat the crab cake")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Eat your crab cake"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    def get_destination(self):
        if self.item.been_in_bathroom:
            return "loserroom"
        else:
            game =get_game()
            return game.history[-1].get_id()
    
    def do_action(self,game,room,request):
        if self.item.been_in_bathroom:
            from rooms.loserroom import loserroom
            from rooms.food import food
            game.food += 1
            thingEaten = game.get_player().pop_item("crab cake")
            destRoom = game.get_room("food", food)
            destRoom.add_item(thingEaten)
            set_cutscene("You brought a crabcake into the bathroom and then ate it? Gross!")
            game.get_room("loserroom", loserroom)
            #return "loserroom"
        else:
            from rooms.food import food
            game.food += 1
            thingEaten = game.get_player().pop_item("crab cake")
            destRoom = game.get_room("food", food)
            destRoom.add_item(thingEaten)
            #return "food"
        return